package org.aplombh.java.interview.newcoder;

import java.util.Arrays;
import java.util.Scanner;

public class HJ103_Redraiment的走法 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int num = in.nextInt();
            int[] a = new int[num + 1];
            for (int i = 1; i <= num; i++) {
                a[i] = in.nextInt();
            }

            // 表示到i的最大长度
            int[] f = new int[num + 1];
            Arrays.fill(f, 1);
            int max = 1;

            for (int i = 2; i <= num; i++) {
                for (int j = 1; j <= i; j++) {
                    if (a[i] > a[j]) f[i] = Math.max(f[i], f[j] + 1);
                }
                if (f[i] > max) max = f[i];
            }
            System.out.println(max);
        }
    }
}